After completing this lesson, you’ll be able to:
There is no 2023 video available for this lesson. You can view the 2022 video instead if you'd like, but remember, it might not match the instructions.
Many FME transformers have a Generate List checkbox under the Attribute Accumulation section of their parameters dialog. For example
For query transformers that can return multiple results, like the PointOnAreaOverlayer, these parameters can be used to generate a list to store the results.
In this scenario, we want to create park polygons with attributes telling us what trees exist in each park. We will merge tree points with park polygons using the PointOnAreaOverlayer. However, it isn't enough to copy attributes from each tree to their respective park polygons because what if there is more than one tree per park?
List attributes are perfect for this scenario: if more than one tree falls within the same park polygon, we can use a list attribute to store information for all trees in each park. The PointOnAreaOverlayer allows us to generate a list that stores the values for all points overlaid on the area.
The workspace will:
Open the starting workspace (C:\FMEData\Workspaces\AdvancedDataTransformation\exercise-create-lists-using-transformers.fmw) in FME Workbench (2024.0 or later).
Run the workspace to generate feature caches.
Inspect the Parks and DataBaseJoiner's Joined cache (the trees) by clicking each cache while holding down the Ctrl or Cmd key. You will find that some parks overlap with more than one tree. For example, China Creek North Park contains two trees (very close together). You can confirm this by following these steps:
How can we get a list of all trees in each park?
Double-click the PointOnAreaOverlayer to open its parameters. By default, the checkboxes under Attribute Accumulation are unchecked, which means the area and point attributes are not being merged, and no list attributes are being created. Check Merge Attributes.
Click OK to close the parameters.
Rerun the workspace and inspect China Creek North Park again, which contains two tree points. The PointOnAreaOverlayer adds an _overlaps
attribute that counts the number of points in each area. In the Feature Information pane, we can see that it has two overlaps, but attributes from only one of the tree species have been added:
This is the result of merging the incoming features. We will need to create a list to include all trees in a given park.
Open the PointOnAreaOverlayer parameters and uncheck Merge Attributes. Instead, check Generate List on Output ‘Area’. Name the list _trees
and use Selected Attributes to select the attributes Common Name
, Diameter, Height, Species, and TreeID.
Click OK to close the parameters.
Run the workspace and inspect China Creek North Park again. The Feature Information pane shows a list attribute, _trees{}
, which contains information from both tree points in the park:
We successfully used the PointOnAreaOverlayer to create a list called _trees{}
, which stores the values of multiple tree points within each park polygon. Note how each numbered list element contains the same attributes: CommonName
, Diameter
, etc.
The next step is to process and analyze the data. For example, a TestFilter can be used to filter out parks that contain no tree points, and then list manipulation transformers can be used for tasks like the following:
Operation | Transformer |
Count the number of trees in each park | ListElementCounter |
Find the maximum tree diameter | ListSorter & ListIndexer |
Find the count of each species | ListHistogrammer |
Create a list of species | ListConcatentaor |
Find which parks have an Oak tree | ListSearcher |
Create a table of park trees with the park name | ListExploder |
Find the average tree height in a park | ListSummer |
Find the minimum/maximum of tree diameters | ListRangeExtractor |
You can learn to use these transformers in the next lesson.